<?php

namespace app\admin\validate;

use think\Validate;

class RoleValidate extends Validate
{
    protected $message = [
        'id.require' => 'ID必须填写',
        'id.integer' => 'ID必须为整数',
        'name.require' => '角色名称必须填写',
        'name.max' => '角色名称最多不能超过20个字符',
        'description.max' => '角色描述最多不能超过255个字符',
        'status.in' => '状态值错误',
        'sort.integer' => '排序必须为整数',
        'page.integer' => '页码必须为整数',
        'page.egt' => '页码必须大于等于1',
        'limit.integer' => '每页数量必须为整数',
        'limit.between' => '每页数量只能在1到100之间',
    ];
    protected $group = [
        'index' => [
            'page' => 'integer|egt:1',
            'limit' => 'integer|between:1,100',
            'name' => 'max:20',
            'status' => 'integer|in:0,1',
        ],
        'info' => [
            'id' => 'require|integer',
        ],
        'create' => [
            'name' => 'require|max:20',
            'description' => 'max:255',
            'status' => 'in:0,1',
            'sort' => 'integer',
        ],
        'update' => [
            'id' => 'require|integer',
            'name' => 'require|max:20',
            'description' => 'max:255',
            'status' => 'in:0,1',
            'sort' => 'integer',
        ],
        'delete' => [
            'id' => 'require|integer',
        ],
        'grantMenus' => [
            'id' => 'require|integer',
        ],
    ];
}